package com.qianli.user.facade.query.impl.frozen;

import com.fqgj.common.api.Response;
import com.qianli.user.application.UserFrozenApplication;
import com.qianli.user.facade.query.frozen.UserFrozenQueryServiceFacade;
import com.qianli.user.ro.UserStateCode;
import com.qianli.user.ro.frozen.UserFrozenRO;
import com.qianli.user.ro.query.UserStatusQueryRO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * name:冷冻信息 查询
 * auth:ting.li@qianli-inc.com
 * date:2018/1/10 15:03
 * version: v1.0.0
 **/
@Service("userFrozenQueryServiceFacade")
public class UserFrozenQueryServiceFacadeImpl implements UserFrozenQueryServiceFacade{

    private static final Logger LOGGER = LoggerFactory.getLogger(UserFrozenQueryServiceFacade.class);

    @Autowired
    private UserFrozenApplication userFrozenApplication;

    /**
     * 查询冷冻信息
     * @param query
     * @return
     */
    @Override
    public Response<List<UserFrozenRO>> queryUserFrozens(UserStatusQueryRO query) {
        if(null == query){
            LOGGER.info("UserFrozenQueryServiceFacade.queryUserFrozens param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK.getMsg());
        }
        if(null == query.getAppCode()||null == query.getBiz()){
            LOGGER.info("UserQueryServiceFacade.getUserByUserCode param appCode and biz can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK.getMsg());
        }
        if(null == query.getUserCode()){
            LOGGER.info("UserFrozenQueryServiceFacade.queryUserFrozens param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK.getMsg());
        }
        Response<List<UserFrozenRO>> response = userFrozenApplication.load(query.getUserCode());
        return response;
    }
}
